<?php
	require_once('preheader.php');
	#the code for the class
	include('ajaxCRUD.class.php');
    #this one line of code is how you implement the class
    ########################################################
    ##

    $tbl = new ajaxCRUD("Passages", "passages", "", "");

    ##
    ########################################################


    #i can define a relationship to another table
    #the 1st field is the fk in the table, the 2nd is the second table, the 3rd is the pk in the second table, the 4th is field i want to retrieve as the dropdown value
    #http://ajaxcrud.com/api/index.php?id=defineRelationship
    $tbl->defineRelationship("room_from", "rooms", "room", "name");
    $tbl->defineRelationship("room_to", "rooms", "room", "name");
    $tbl->defineRelationship("door", "doors", "door", "door");


    #i don't want to visually show the primary key in the table
    //$tbl->omitPrimaryKey();

    #i want to give the heading titles something more meaningful
    $tbl->displayAs("room_from", "Room");
    $tbl->displayAs("room_to", "Destiny");
    $tbl->displayAs("door", "Door ID");
    $tbl->displayAs("direction", "Direction");

	#set the textarea height of the longer field (for editing/adding)
    #http://ajaxcrud.com/api/index.php?id=setTextareaHeight
    //$tbl->setTextareaHeight('description', 200);

    #i could omit a field if I wanted
    #http://ajaxcrud.com/api/index.php?id=omitField
    //$tbl->omitField("waist");

    #i could omit a field from being on the add form if I wanted
    $tbl->omitAddField("door");

    #i could disallow editing for certain, individual fields
   // $tbl->disallowEdit('behaviour');

    #i could set a field to accept file uploads (the filename is stored) if wanted
    //$tbl->setFileUpload("fldField2", "uploads/");

    #i can have a field automatically populate with a certain value (eg the current timestamp)
    //$tbl->addValueOnInsert("door", NULL);

    #i can use a where field to better-filter my table
    //$tbl->addWhereClause("WHERE (fldField1 = 'test'");

    #i can order my table by whatever i want
    //$tbl->addOrderBy("ORDER BY name ASC");

    #i can set certain fields to only allow certain values
    #http://ajaxcrud.com/api/index.php?id=defineAllowableValues
    //$allowableValues = array("Allowable Value 1", "Allowable Value2", "Dropdown Value", "CRUD");
    //$tbl->defineAllowableValues("fldCertainFields", $allowableValues);

    #i can disallow deleting of rows from the table
    #http://ajaxcrud.com/api/index.php?id=disallowDelete
    $tbl->disallowDelete();

    #i can disallow adding rows to the table
    #http://ajaxcrud.com/api/index.php?id=disallowAdd
    //$tbl->disallowAdd();

    #i can add a button that performs some action deleting of rows for the entire table
    #http://ajaxcrud.com/api/index.php?id=addButtonToRow
    //$tbl->addButtonToRow("Add", "add_item.php", "all");

    #set the number of rows to display (per page)
    $tbl->setLimit(30);

	#set a filter box at the top of the table
    $allowable_vals   = array("north","east", "west","south","up","down");
    $tbl->defineAllowableValues("direction", $allowable_vals);
    #if really desired, a filter box can be used for all fields
    $tbl->addAjaxFilterBoxAllFields();

    #i can set the size of the filter box
    //$tbl->setAjaxFilterBoxSize('fldField1', 3);

	#i can format the data in cells however I want with formatFieldWithFunction
	#this is arguably one of the most important (visual) functions
	//$tbl->formatFieldWithFunction('password', 'hashIt');

	$tbl->onAddSpecifyPrimaryKey();

	include('header.php');

	#actually show the table
	$tbl->showTable();

	include('footer.php');

	#my self-defined functions used for formatFieldWithFunction
	/*function hashIt($val){
		return sha1($val);
	}*/



?>

